/*
package com.zijin.controller;

import com.zijin.entity.Result;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

*/
/**
 * Copyright: Copyright (c) 2020 TD
 *
 * <p> Description:
 *
 * @author lius
 * @version 1.0.0
 * @date 2020/12/08 2020/12/8:11:28 下午
 *//*

@RequestMapping("userInfo")
@RestController
public class UserInfoController {

    private final Logger log = LoggerFactory.getLogger(UserInfoController.class);

    @Autowired
    private QiniuService qiniuService;
    @Autowired
    private UserInfoService infoService;
    @Autowired
    private TokenUtils tokenUtils;
    @Autowired
    private FormInfoService formInfoService;

    */
/**
     * 身份证正面照上传
     *//*

    @RequestMapping("surface")
    public Result surface(@RequestParam(value = "file", required = true) MultipartFile file,
                          @RequestParam(value = "username", required = true) String username) {
        if (StringUtils.isEmpty(username)) {
            return Result.error("先填写用户名！", null);
        }
        String upload = null;
        try {
            upload = qiniuService.upload(file, username + "身份证正面" + TimeUtils.getTimeStr() +".jpg");
        } catch (IOException e) {
            log.error("身份证正面照上传失败");
            Result.error("身份证正面照上传失败", null);
        }
        return Result.success("身份证正面照上传成功", "http://" + upload);
    }

    */
/**
     * 身份证反面面照上传
     *//*

    @RequestMapping("unSurface")
    public Result unSurface(@RequestParam(value = "file", required = true) MultipartFile file,
                            @RequestParam(value = "username", required = true) String username) {
        if (StringUtils.isEmpty(username)) {
            return Result.error("先填写用户名！", null);
        }
        String upload = null;
        try {
            upload = qiniuService.upload(file, username + "身份证反面" + TimeUtils.getTimeStr() +".jpg");
        } catch (IOException e) {
            log.error("身份证反面面照上传失败");
            Result.error("身份证反面面照上传失败", null);
        }
        return Result.success("身份证反面面照上传成功", "http://" + upload);
    }

    */
/**
     * 注册
     *//*

    @RequestMapping("reg")
    public Result reg(@RequestParam(value = "username") String username,
                      @RequestParam(value = "sex") String sex,
                      @RequestParam(value = "country") String country,
                      @RequestParam(value = "idCard") String idCard,
                      @RequestParam(value = "idCardNo") String idCardNo,
                      @RequestParam(value = "phoneNo") String phoneNo,
                      @RequestParam(value = "surfacePath") String surfacePath,
                      @RequestParam(value = "unSurfacePath") String unSurfacePath) {
        if (StringUtils.isEmpty(username)) {
            return Result.error("用户名不能为空", null);
        }
        if (StringUtils.isEmpty(sex)) {
            return Result.error("性别不能为空", null);
        }
        if (StringUtils.isEmpty(idCardNo)) {
            return Result.error("证件号码不能为空", null);
        }
        if (StringUtils.isEmpty(phoneNo)) {
            return Result.error("手机号码不能为空", null);
        }
        if (StringUtils.isEmpty(surfacePath)) {
            return Result.error("获取身份证正面照地址失败，请稍后重试", null);
        }
        if (StringUtils.isEmpty(unSurfacePath)) {
            return Result.error("获取身份证反面照地址失败，请稍后重试", null);
        }


//        String ocrCardNo = IOCRUtils.getIdCardNo(surfacePath);
//        if (!ocrCardNo.equalsIgnoreCase(idCardNo)) {
//            return Result.error("身份证号码与身份证照片不一致", null);
//        }

        int count = infoService.count(new LambdaQueryWrapper<UserInfo>().eq(UserInfo::getIdCardNo, idCardNo));
        if (count > 0) {
            return Result.error("该身份证号码已注册", null);
        }

        UserInfo info = new UserInfo();
        info.setUsername(username);
        info.setSex(sex);
        info.setCountry(country);
        info.setIdCard(idCard);
        info.setIdCardNo(idCardNo);
        info.setPhoneNo(phoneNo);
        info.setSurfacePath(surfacePath);
        info.setUnSurfacePath(unSurfacePath);
        return infoService.reg(info) ? Result.success("注册成功！", null) : Result.error("注册失败，请稍后重试", null);
    }

    */
/**
     * 登录
     *//*

    @RequestMapping("login")
    public Result login(@RequestParam(value = "idCardNo") String idCardNo) {
        if (StringUtils.isEmpty(idCardNo)) {
            return Result.error("身份证号码不能为空", null);
        }
        UserInfo one = infoService.getOne(new LambdaQueryWrapper<UserInfo>().eq(UserInfo::getIdCardNo, idCardNo));
        if (one == null) {
            return Result.error(idCardNo + "用户不存在！", null);
        }
        // 签发token并存储
        String token = tokenUtils.createToken(one.getId(), one.getIdCardNo());
        boolean update = infoService.update(new LambdaUpdateWrapper<UserInfo>().set(true, UserInfo::getToken, token).eq(UserInfo::getIdCardNo, idCardNo));
        return update ? Result.success("登录成功", token) : Result.error("登录失败", null);
    }

}
*/
